package com.supermate.init.dto;

import lombok.Data;

import java.util.Collection;

@Data
public class MultiResult<T> extends BaseRpcResult{

    private Collection<T> data;

    public static <T> MultiResult<T> success(Collection<T> data) {
        MultiResult<T> res = new MultiResult<T>();
        res.setData(data);
        res.setIfSuccess(true);
        return res;
    }

    public static MultiResult<Void> fail(String errMsg) {
        MultiResult<Void> res = new MultiResult<Void>();
        res.setIfSuccess(false);
        res.setErrMsg(errMsg);
        return res;
    }

    public static MultiResult fail(String errCode, String errMsg) {
        MultiResult res = fail(errMsg);
        res.setErrCode(errCode);
        return res;
    }

}
